<?php

namespace App\Models\Lst;

use Illuminate\Database\Eloquent\Model;
use Laracasts\Presenter\PresentableTrait;

class Student extends Model
{
    //use PresentableTrait;

    protected $table = 'lst_students';

    protected $guarded = array();

    //protected $presenter = 'App\Http\Presenters\EnrolPresenter';

    public function branch()
    {
        return $this->belongsTo('\App\Models\Mgt\Branch');
    }


    public function type()
    {
        return $this->belongsTo('\App\Models\Edu\Type');
    }


    public function term()
    {
        return $this->belongsTo('\App\Models\Edu\Term');
    }


    public function category()
    {
        return $this->belongsTo('\App\Models\Edu\Category');
    }


    public function clase()
    {
        return $this->belongsTo('\App\Models\Edu\Clase');
    }


    public function info()
    {
        return $this->belongsTo('\App\Models\Mgt\User','uid');
    }

    /**
     * 所属花名册过滤器
     * @param  [type] $query  [description]
     * @param  [type] $branch [description]
     * @return [type]         [description]
     */
    public function scopeWherePublish($query, $publishId)
    {
        return $query->where('publish_id', $publishId);
    }

    /**
     * 所属班级过滤器
     * @param  [type] $query [description]
     * @param  [type] $type  [description]
     * @return [type]        [description]
     */
    public function scopeWhereClase($query, $claseId)
    {
        return $query->where('clase_id', $claseId);
    }

}